package com.sfeir.fastcall.utility;

import android.graphics.Bitmap;
import android.graphics.Matrix;

/**
 * Created by :
 * 
 * 		@author SFEIR
 */

public class ResizeImage {
	public static Bitmap resizeImage(Bitmap bitmapOrg, float density){
		
		Matrix matrix = new Matrix();
		int width = bitmapOrg.getWidth();
		int height = bitmapOrg.getHeight();
		int newWidth = (int) (45 * density);
		int newHeight = (int) (45 * density);

		
		// calculate the scale - in this case = 0.4f
		float scaleWidth = ((float) newWidth) / width;
		float scaleHeight = ((float) newHeight) / height;

		// createa matrix for the manipulation
		matrix = new Matrix();
		// resize the bit map
		matrix.postScale(scaleWidth, scaleHeight);

		// recreate the new Bitmap
		Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0,
				width, height, matrix, true);
		matrix = null;
		
		return resizedBitmap;
	}

}
